From: Jo-Philipp Wich Date: Wed, 26 Jan 2022 10:01:55 +0000 (+0100) Subject: fw4: fix family comparisons X-Git-Url: http://git.openwrt.org/%22https:/collectd.org//%22%24PHP_SELF/%22https:/collectd.org/%22%24PHP_SELF?a=commitdiff_plain;h=101988d2ec1fee6d37f57e99e31d37554918447e;p=project%2Ffirewall4.git fw4: fix family comparisons The address family of an object might be either `0` or `null` so loosen the checks to accomodate both. Ref: https://github.com/jow-/ucode/commit/aa860a35252b4833a188f8b2f9c6a7d68963767d Signed-off-by: Jo-Philipp Wich --- diff --git a/root/usr/share/ucode/fw4.uc b/root/usr/share/ucode/fw4.uc index 6973eae..113e4f5 100644 --- a/root/usr/share/ucode/fw4.uc +++ b/root/usr/share/ucode/fw4.uc @@ -264,9 +264,9 @@ function ensure_tcpudp(x) { return false; } -let is_family = (x, v) => (x.family == 0 || x.family == v); -let family_is_ipv4 = (x) => (x.family == 0 || x.family == 4); -let family_is_ipv6 = (x) => (x.family == 0 || x.family == 6); +let is_family = (x, v) => (!x.family || x.family == v); +let family_is_ipv4 = (x) => (!x.family || x.family == 4); +let family_is_ipv6 = (x) => (!x.family || x.family == 6); function infer_family(f, objects) { let res = f; @@ -277,7 +277,7 @@ function infer_family(f, objects) { desc = objects[i + 1]; for (let obj in objs) { - if (!obj || obj.family == 0 || obj.family == res) + if (!obj || !obj.family || obj.family == res) continue; if (res == 0) {